const mysql = require('mysql2/promise');
const config = require('../config/database').mysql;

async function checkSchema() {
  try {
    // 创建数据库连接
    const connection = await mysql.createConnection({
      host: config.host,
      user: config.user,
      password: config.password,
      database: config.database,
      port: config.port
    });
    
    console.log('开始检查数据库表结构...');
    
    // 查询bid_goods表的结构
    const [goodsColumns] = await connection.query(
      "SHOW COLUMNS FROM bid_goods"
    );
    
    console.log('\nbid_goods表结构:');
    goodsColumns.forEach(col => {
      console.log(`${col.Field} (${col.Type}) - ${col.Key}`);
    });
    
    // 查询bid_goods_attributes表的结构
    const [attributesColumns] = await connection.query(
      "SHOW COLUMNS FROM bid_goods_attributes"
    );
    
    console.log('\nbid_goods_attributes表结构:');
    attributesColumns.forEach(col => {
      console.log(`${col.Field} (${col.Type}) - ${col.Key}`);
    });
    
    // 关闭连接
    await connection.end();
    console.log('\n数据库表结构检查完成');
    
  } catch (error) {
    console.error('❌ 检查数据库表结构失败:', error.message);
  }
}

checkSchema();